package com.dkd.http.controller;


import com.dkd.client.entity.RepairCountDto;
import com.dkd.service.TaskService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 工单
 */
@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/task")
public class TaskController {
    private final TaskService taskService;
    @ApiOperation("获取售货机维修次数")
    @GetMapping("/repairCount/{innerCode}/{start}/{end}")
    public Integer getRepairCount(@PathVariable("innerCode") String innerCode,
                                  @PathVariable("start") @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate start,
                                  @PathVariable("end") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end
            , RepairCountDto repairCountDto
                                  ){

        log.info("innercode={},start={},end={}",innerCode,start,end);
        return taskService.getRepairCount(innerCode,start,end, repairCountDto);
    }

    @ApiOperation("获取售货机补货次数")
    @GetMapping("/supplyCount/{innerCode}/{start}/{end}")
    public Integer getSupplyCount(@PathVariable("innerCode") String innerCode,
                                  @PathVariable("start") @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate start,
                                  @PathVariable("end") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end
            , RepairCountDto repairCountDto
    ){

        log.info("innercode={},start={},end={}",innerCode,start,end);
        return taskService.getSupplyCount(innerCode,start,end, repairCountDto);
    }


}